package com.huage_08.lesson_05;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //创建客户端的Socket对象
        Socket client = new Socket("192.168.56.1",1997);

        //向服务端发送数据
        OutputStream os = client.getOutputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
//        while ((line=br.readLine())!=null){
//            if (line.equals("886")){
//                break;
//            }
//            os.write(line.getBytes());
//        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
        while ((line=br.readLine())!=null){
            if (line.equals("886")){
                break;
            }
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
       //关闭客户端的Socket对象
       client.close();

    }
}
